const { override, addWebpackAlias, adjustStyleLoaders, overrideDevServer,useEslintRc } = require('customize-cra');
const path = require('path');
const resolve = _path => path.resolve(__dirname, _path)
module.exports = {
    webpack: override(
        // 添加webpack别名
        addWebpackAlias({
            // 添加路径对@符号的支持
            ["@"]: resolve('./src'),
        }),
        // useEslintRc(resolve('./.eslintrc.js')),
        adjustStyleLoaders(rule => {
            if (rule.test.toString().includes('scss')) {
                rule.use.push({
                    loader: require.resolve('sass-resources-loader'),
                    options: {
                        resources: [resolve("./src/styles/theme.scss")]
                    }
                });
            }
        }),
    ),
    devServer: overrideDevServer([
        config => ({
            ...config,
            proxy: {
                // "/api": {
                //     target: "http://localhost:4444",
                //     pathRewrite: { "^/api": "" }
                // }
            },
            headers: {
                'Access-Control-Allow-Origin': '*',
            },
            open: true,
            overlay: {
              warnings: false,
              errors: true,
            },
            before: require("./mock/mock-server.js"),
        })
    ]),
}
